<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="./template.xhtml">

    <ui:define name="title">
        DataTable - <span class="subitem">Sort</span>
    </ui:define>

    <ui:define name="description">
        Sorting is enabled with sortBy expressions. Both single and multiple column sorting are supported.
    </ui:define>

    <ui:param name="documentationLink" value="/components/datatable" />
    
    <ui:define name="head">
        <style type="text/css">
            .ui-datatable input {
                box-sizing: border-box;
                width: 100%;
                -webkit-box-shadow: none;
                box-shadow: none !important;
            }
        </style>
    </ui:define>

    <ui:define name="implementation">
        
        <h:form>
            <p:dataTable var="car" value="#{dtSortView.cars1}" style="margin-bottom:40px">
                <f:facet name="header">
                    Single Column Sort
                </f:facet>
                <p:column headerText="Id" sortBy="#{car.id}">
                    <h:outputText value="#{car.id}" />
                </p:column>

                <p:column headerText="Year" sortBy="#{car.year}">
                    <h:outputText value="#{car.year}" />
                </p:column>

                <p:column headerText="Brand" sortBy="#{car.brand}">
                    <h:outputText value="#{car.brand}" />
                </p:column>

                <p:column headerText="Color" sortBy="#{car.color}">
                    <h:outputText value="#{car.color}" />
                </p:column>
            </p:dataTable>
            
            <p:dataTable var="car" value="#{dtSortView.cars2}" style="margin-bottom:40px">
                <f:facet name="header">
                    Editable Values
                </f:facet>
                <p:ajax event="sort" skipChildren="false" />
                <p:column headerText="Id" sortBy="#{car.id}">
                    <p:inputText value="#{car.id}" />
                </p:column>

                <p:column headerText="Year" sortBy="#{car.year}">
                    <p:inputText value="#{car.year}" />
                </p:column>

                <p:column headerText="Brand" sortBy="#{car.brand}">
                    <p:inputText value="#{car.brand}" />
                </p:column>

                <p:column headerText="Color" sortBy="#{car.color}">
                    <p:inputText value="#{car.color}" />
                </p:column>
            </p:dataTable>
            
            <p:dataTable var="car" value="#{dtSortView.cars3}" sortMode="multiple">
                <f:facet name="header">
                    Multiple Column Sort with Metakey
                </f:facet>
                <p:column headerText="Id" sortBy="#{car.id}">
                    <h:outputText value="#{car.id}" />
                </p:column>

                <p:column headerText="Year" sortBy="#{car.year}">
                    <h:outputText value="#{car.year}" />
                </p:column>

                <p:column headerText="Brand" sortBy="#{car.brand}">
                    <h:outputText value="#{car.brand}" />
                </p:column>

                <p:column headerText="Color" sortBy="#{car.color}">
                    <h:outputText value="#{car.color}" />
                </p:column>
            </p:dataTable>
        </h:form>
        
    </ui:define>

</ui:composition>